//生产机器
function* fibs() {

	let a = 1
	while (a < 10) {
		yield [a, a * 2] //产物  0 1 2 3 4 5 .....
		a++
	}

}

for (let s of fibs()) {
	console.log(s)
}

//setPrototypeOf实现继承
const obj1 = {};
const obj2 = {
	foo: 'bar'
};
Object.setPrototypeOf(obj1, obj2);
console.log(obj1.__proto__, obj2)

//sort  对象排序
var arr2 = [{
		qq: 20
	},
	{
		qq: 25
	},
	{
		qq: 17
	}
]
console.log(arr2)
console.log(arr2.sort(function(a, b) { //只需对比较的属性按照数字比较即可
	console.log(a, b)
	return a.qq - b.qq
}))

//字符串解码  参数为解码位置
var str = "HELLO WORLD";
var n = str.charCodeAt(0);

//懒判断
console.log(0 || 0==0 || 1==13)

//map
const map = new Map();
map.set('first', 'hello'); //数组的形式存放[]
map.set('second', 'world');

for (let s of map) {
  console.log(s);
}

